﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using Intelligent.OTC.Common.UnitOfWork;
using Intelligent.OTC.Business;
using Intelligent.OTC.Common;
using System.Configuration;
using System.IO;
using Intelligent.OTC.Common.Utils;
using Intelligent.OTC.WebApi.Core;
using Intelligent.OTC.Common.Exceptions;
using Intelligent.OTC.Domain.DataModel;
using Intelligent.OTC.Common.Attr;

namespace Intelligent.OTC.WebApi.Controllers
{
    [UserAuthorizeFilter(actionSet: "common")]
    public class WorkFlowController : ApiController
    {
        [HttpPost]
        public void Wfchange(string referenceNo, string status,string type) {
            IWorkflowService service = SpringFactory.GetObjectImpl<IWorkflowService>("WorkflowService");
            //int count = service.GetPStatus(referenceNo, status);

            if (type == "start")
            {
                //start a instance check must have no instance
                //if (count == 0)
                //{
                service.Wfchange("4", referenceNo, type);
                //    return "successed";
                //}
                //else {
                //    return "failed";
                //}
            }
            else
            {
                //other need a instance exist
                //if (count > 0)
                //{
                service.Wfchange("4", referenceNo, type);
                //    return "successed";
                //}
                //else {
                //    return "failed";
                //}
            }
            
        }
    }
}